let BaseBean = require('./BaseControl');
let comDriver = require('@/common/driver');

class Bean extends BaseBean{
    constructor(param = {}) {
        super(param);
    }

    async build(form){
        await super.build(form);
        form.param.vMethod[this.vKey('change')] = (value) => { if (this.param.onChange) this.param.onChange(value);};
    }

    showData(data) {
        if (!data) return;
        let field = this.param.showField || this.param.field;
        if (!field) return;
        this.value = data[field] ? true : false;
    }

    packageData(data) {
        let field = this.param.packageField || this.param.field;
        if (!field) return;
        data[field] = this.value ? 1 : 0;
    }
}


module.exports = Bean;
